<?php
namespace app\api\controller;
use think\Controller;

class Category extends Controller  //api
{
    //构造函数 私有属性
	private $obj;
	public function _initialize(){
		$this->obj = model("Category");
		}
	
	
	public function getCategoryByParentId()
    {
         $id = input('post.id', 0, 'intval');
		 if(!$id){
			 $this->error('ID不合法');
			 }
		//通过id获得二级分类
		$categorys = $this->obj->getNormalCategorysByParentId($id);
		if(!$categorys){
			    return show(0, 'error');
			}else{
		        return show(1, 'success', $categorys);
			}
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
}
?>